<%--
  Created by IntelliJ IDEA.
  User: EDY
  Date: 2023-10-26
  Time: 16:53
  To change this template use File | Settings | File Templates.
--%>
<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="../../js/jquery-3.3.1.js"></script>
    <script src="../../js/bootstrap-table.min.js"></script>
    <script src="../../js/bootstrap.bundle.min.js"></script>
    <script src="../../js/bootstrap-table-zh-CN.min.js"></script>
    <script src="../../js/jquery.form.js"></script>
    <script src="../../js/jquery.validate.js"></script>
    <script src="../../js/messages_zh.js"></script>
    <link rel="stylesheet" href="../../css/bootstrap-table.min.css"></link>
    <link rel="stylesheet" href="../../css/bootstrap.min.css"></link>
    <style>
        #form {
            position: absolute;
            top: 10%;
            bottom: 10%;
            left: 10%;
            right: 10%;
            margin: auto;
        }
    </style>
</head>
<body>

<form id="productRegister">
    <table class="TABLE_STYLE2" width="100%">
        <tbody>
        <tr height="20" class="TR_STYLE1">
            <td class="TD_HANDBOOK_STYLE1"><span style="color: #0c84ff">您正在做的业务是：产品设计--产品档案管理--产品档案登记</span></td>
        </tr>
        <tr height="20" class="TR_STYLE1">
            <td align="right">
                <div class="DIV_STYLE1">
                    <input type="submit" value="提交">
                    <input type="reset" id="resetButton" value="清除">
                </div>
            </td>
        </tr>
        </tbody>
    </table>
    <div id="form">
        <table border="0" cellspacing="1"
               cellpadding="1" bgcolor="#EEEEEE" align="center">
            <tbody>
            <tr>
                <td colspan="4">
                    <div style="background: #0c84ff;width:100%; line-height:10px; padding:5px; color:#FFFFFF; font-weight:bold ">
                        主信息
                    </div>
                </td>
            </tr>
            <tr height="20" class="TR_STYLE1">
                <td bgcolor="#D2E9FF" align="right">
                    <font color="red">*</font>产品名称
                </td>
                <td width="37.4%">
                    <input type="text" style="width:80%" name="productName" required>
                </td>
                <td bgcolor="#D2E9FF" align="right">
                    制造商
                </td>
                <td width="37.4%">
                    <input type="text" name="factoryName" style="width:80%">
                </td>
            </tr>
            <tr>
                <td bgcolor="#D2E9FF" align="right">
                    <font color="red">*</font>I级分类
                </td>
                <td bgcolor="#eeeeee" width="13%">
                    <select name="select1" style="width:49%" required>
                        <option value="">&nbsp;</option>
                        <option value="01/电子">01/电子</option>
                    </select>
                </td>
                <td bgcolor="#D2E9FF" align="right">
                    <font color="red">*</font>II级分类
                </td>
                <td bgcolor="#eeeeee" width="13%">
                    <select name="select2" style="width:49%" required>
                        <option value=""></option>
                        <option value="01/计算机">01/计算机</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td bgcolor="#D2E9FF" align="right">
                    <font color="red">*</font>III级分类
                </td>
                <td bgcolor="#eeeeee" width="13%">
                    <select name="select3" style="width:49%" required>
                        <option value=""></option>
                        <option value="01/服务器">01/服务器</option>
                    </select>
                </td>
                <td bgcolor="#D2E9FF" align="right">
                    产品简称
                </td>
                <td bgcolor="#eeeeee" width="13%">
                    <input type="text" name="productNick" style="width:49%">
                </td>
            </tr>
            <tr>
                <td bgcolor="#D2E9FF" align="right">
                    用途类型
                </td>
                <td bgcolor="#eeeeee" width="13%">
                    <select name="type" style="width:49%">

                        <option value="Y001-1">商品</option>

                        <option value="Y001-2">物料</option>

                    </select>
                </td>
                <td bgcolor="#D2E9FF" align="right">
                    档次级别
                </td>
                <td bgcolor="#eeeeee" width="13%">
                    <select name="productClass" style="width:49%">

                        <option value="D001-1">高档</option>

                        <option value="D001-2">中档</option>

                        <option value="D001-3">低档</option>

                    </select>
                </td>
            </tr>
            <tr>
                <td bgcolor="#D2E9FF" align="right">
                    计量单位
                </td>
                <td bgcolor="#eeeeee" width="13%">
                    <input type="text" name="personalUnit" style="width:49%">
                </td>
                <td bgcolor="#D2E9FF" align="right">
                    计量值
                </td>
                <td bgcolor="#eeeeee" width="13%">
                    <input type="text" name="personalValue" style="width:49%">
                </td>
            </tr>
            <tr>
                <td bgcolor="#D2E9FF" align="right">
                    市场单价(元)
                </td>
                <td bgcolor="#eeeeee" width="13%">
                    <input type="text" name="listPrice" readonly  style="outline: none;border:0px;background:#eeeeee;width:49%">
                </td>
                <td bgcolor="#D2E9FF" align="right" width="12%">
                    <font color="red">*</font>计划成本单价
                </td>
                <td bgcolor="#eeeeee" width="13%">
                    <input name="costPrice" type="text" style="width:49%" required>
                </td>
            </tr>
            <tr>
                <td colspan="4">
                    <div style="background: #0c84ff;width:100%; line-height:10px; padding:5px; color:#FFFFFF; font-weight:bold ">
                        辅助信息
                    </div>
                </td>
            </tr>

            <tr>
                <td bgcolor="#D2E9FF" align="right">
                    保修期
                </td>
                <td bgcolor="#eeeeee" width="13%">
                    <input type="text" name="warranty" style="width:49%">
                </td>
                <td bgcolor="#D2E9FF" align="right">
                    替代品名称
                </td>
                <td bgcolor="#eeeeee" width="13%">
                    <input type="text" name="twinName" style="width:49%">
                </td>
            </tr>
            <tr>
                <td bgcolor="#D2E9FF" align="right">
                    替代品编号
                </td>
                <td bgcolor="#eeeeee" width="13%">
                    <input type="text" name="twinId" style="width:49%">
                </td>
                <td bgcolor="#D2E9FF" align="right">
                    生命周期(年)
                </td>
                <td bgcolor="#eeeeee" width="13%">
                    <input type="text" name="lifecycle" style="width:49%">
                </td>
            </tr>
            <tr>

                <td bgcolor="#D2E9FF" align="right">
                    单位
                </td>
                <td bgcolor="#eeeeee" width="13%">
                    <input type="text" name="amountUnit" style="width:49%">
                </td>
                <td bgcolor="#D2E9FF" align="right">
                    产品经理
                </td>
                <td bgcolor="#eeeeee" width="13%">
                    <select name="responsiblePerson" style="width:66%">
                        <option value=""></option>
                    </select></td>
            </tr>
            <tr>
                <td bgcolor="#D2E9FF" align="right" width="11%" height="65">
                    供应商集合 &nbsp;
                </td>
                <td bgcolor="#eeeeee" width="13%">
                    <textarea rows="4" name="providerGroup"></textarea>
                </td>
                <td bgcolor="#D2E9FF" align="right" width="11%" height="65px">
                    产品描述 &nbsp;
                </td>
                <td bgcolor="#eeeeee" width="13%">
                    <textarea rows="4" name="productDescribe"></textarea>
                </td>
            </tr>
            <tr>

                <td bgcolor="#D2E9FF" align="right">
                    登记人
                </td>
                <td bgcolor="#eeeeee" width="13%">
                    <input type="text" style="width:49%" readonly="readonly" name="register">
                </td>
                <td bgcolor="#D2E9FF" align="right">
                    建档时间
                </td>
                <td valign="top" bgcolor="#eeeeee">
                    <input type="text" readonly="readonly" style="border: 0px;background:#EEEEEE;outline: none " name="registerTime"
                    id="registerTime"  width="100%">
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</form>
<script>
    $(":input[name=registerTime]").val(new Date().toLocaleString())
    document.getElementById("resetButton").onclick = function(){
        var myInput = document.getElementById("registerTime");
        myInput.defaultValue = myInput.value;
        document.forms[0].reset()
    }
    $(function () {
        $(":input[name='register']").val('${sysUsers.loginId}');
        $("#productRegister").validate({
            submitHandler:function () {
                $("#productRegister").ajaxSubmit({
                    url:"/DFile/productRegister",
                    type:"post",
                    dataType:"json",
                    success:function (data) {
                        alert(data.msg)
                        if(data.code=='1'){
                            location.href="register.jsp";
                        }
                    }
                })
            }
        })
    })
    $(":input[name=productName]").blur(function(){
        let productName=$(this).val()
        $.ajax({
            type:"post",
            url:"/DFile/productRename",
            data:{productName:productName},
            dataType:"json",
            success:function(data){
                if(data.code=='-1'){
                    alert(data.msg);
                    $(":input[name=productName]").val("")
                }
            }
        });
    })
</script>
</div>
</body>
</html>
